<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head> 
<body>
    <div>
        <input type="text"> <b>VS</b> <input type="text"> <button> 最大的数是</button> &ensp; <span>99</span>
    </div>
</body>

<script>
    var input = document.querySelectorAll("input")
    var button=document.querySelector("button")
    console.log(input[0])
    console.log(input[1])
    var span = document.querySelector("span")
    //限制框内输入的内容
    for (var i = 0; i < input.length - 1; i++) {
        input[i].onkeyup = function () {
            this.value = this.value.replace(/[^\d]/, '')
        }
        //数据比较
        function match() {
            var j = 0,
                j = parseInt(input[0].value) >= parseInt(input[1].value) ? parseInt(input[0].value) : parseInt(input[1].value)
            return j
        }
        //点击button按钮比较大小
        button.onclick = function () { 
            span.innerHTML = match() 
        }
    }

</script>

</html>
<style>
    div {
        text-align: center;
    }
</style>